package com.hxx.controller;

import jakarta.annotation.Resource;
import org.springframework.ai.embedding.EmbeddingModel;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;

@RestController
public class QinwenController2 {

    @Resource
    private EmbeddingModel embeddingModel;

    @GetMapping(value = "/embedding", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
    public String getEmbedding(String text){
        // 获取嵌入向量
        float[] embed = embeddingModel.embed(text);
        return Arrays.toString(embed);
    }
}
